package com;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.DeliverCallback;
import com.util.RabbitmqUtils;

import java.util.concurrent.TimeUnit;

public class ConsumerApp1 {
    public static void main(String[] args) {
        while (true) {
            DeliverCallback deliverCallback = (consumerTag, message) -> {
                // 处理消息
                byte[] body = message.getBody();
                String content = new String(body);
                System.out.println("消费者1号消费的消息：" + content);
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            };
            CancelCallback cancelCallback = consumerTag -> {
                System.out.println("消费者1号取消消费消息：" + consumerTag);
            };
            System.out.println("消费者1号启动,等待消费！！！");
            RabbitmqUtils.receiveByWQ("test2", false, false,
                    false, null, deliverCallback, cancelCallback);
        }
    }
}
